//
//  XJRecommendGoodsHeader.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/10.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJRecommendGoodsHeader.h"

@interface XJRecommendGoodsHeader ()

@property (nonatomic ,strong) UIView * xjrg_line;
@property (nonatomic ,strong) UILabel * xjrg_tipsLab;
@property (nonatomic ,strong) UIButton * xjrg_moreBtn;

@end

@implementation XJRecommendGoodsHeader

- (UILabel *)xjrg_tipsLab{
    if (!_xjrg_tipsLab) {
        UILabel * xjrg_tipsLab = [UILabel new];
        self.xjrg_tipsLab = xjrg_tipsLab;
        [self addSubview:xjrg_tipsLab];
    }
    return _xjrg_tipsLab;
}

- (UIButton *)xjrg_moreBtn{
    if (!_xjrg_moreBtn) {
        UIButton * xjrg_moreBtn = [UIButton new];
        self.xjrg_moreBtn = xjrg_moreBtn;
        [self addSubview:xjrg_moreBtn];
    }
    return _xjrg_moreBtn;
}

- (UIView *)xjrg_line{
    if (!_xjrg_line) {
        UIView * xjrg_line = [UIView new];
        self.xjrg_line =xjrg_line;
        [self addSubview:xjrg_line];
    }
    return _xjrg_line;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self= [super initWithFrame:frame]) {
        
        self.backgroundColor = WHITE_COLOR;
        
        self.xjrg_line.backgroundColor = XJCOLOR_RGB(221, 221, 221);
        self.xjrg_line.frame = CGRectMake(10, 0.5, KWidth-20, 0.5);
        self.xjrg_tipsLab.text = @"推荐商品";
        self.xjrg_tipsLab.font = XJFONTSET_M(16);
        self.xjrg_tipsLab.textColor = XJCOLOR_RGB(17, 17, 17);
        CGFloat xjrg_tipsLabW = [UILabel labelWithLabel:self.xjrg_tipsLab getWidthWithTitle:self.xjrg_tipsLab.text font:self.xjrg_tipsLab.font];
        CGFloat xjrg_tipsLabH = [UILabel labelWithLabel:self.xjrg_tipsLab getHeightByWidth:xjrg_tipsLabW title:self.xjrg_tipsLab.text font:self.xjrg_tipsLab.font];
        self.xjrg_tipsLab.sd_layout
        .leftSpaceToView(self, ADAPTWidth(16))
        .centerYEqualToView(self)
        .widthIs(xjrg_tipsLabW)
        .heightIs(xjrg_tipsLabH);
        
        [self.xjrg_moreBtn buttonWithTitle:@"查看更多" titleFont:XJFONTSET_R(14) titleColor:XJCOLOR_RGB(157, 165, 168) imageType:ImageTypeImg imageName:@"direction_right_gray" withTarget:self action:@selector(xjrg_moreBtnClick) style:ImgTextBtnStyleRight margin:15];
        self.xjrg_moreBtn.sd_layout
        .rightSpaceToView(self, UI_IS_IPHONE5?ADAPTWidth(20):ADAPTWidth(12))
        .centerYEqualToView(self)
        .widthIs(UI_IS_IPHONE5?ADAPTWidth(80):ADAPTWidth(70))
        .heightIs(ADAPTHeight(20));
        
    }
    return self;
}

- (void)xjrg_moreBtnClick{
    
    if (_delegate && [_delegate respondsToSelector:@selector(xjrg_moreBtnAction)]) {
        [_delegate xjrg_moreBtnAction];
    }
    XJLog(@"推荐商品查看更多");
}


@end
